package cn.huaguo.infrastructure.persistent.repository;

import cn.huaguo.domain.wallet.model.entity.WalletEntity;
import cn.huaguo.domain.wallet.repository.IWalletRepository;
import cn.huaguo.infrastructure.persistent.dao.IWalletDao;
import cn.huaguo.infrastructure.persistent.po.Wallet;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @Description 钱包仓储接口实现类
 * @Author wangQian
 * @Date 2024/5/13
 */
@Repository
public class WalletRepository implements IWalletRepository {
    @Resource
    private IWalletDao walletDao;

    @Override
    public WalletEntity getWalletInfo(String userId) {
        Wallet wallet = walletDao.getWalletInfo(userId);
        return WalletEntity.builder()
                .balance(wallet.getBalance())
                .userId(wallet.getUserId())
                .build();
    }
}
